package com.bp.hearthealth.pulse.lnapps.ads.topon.interstitial_ad.listener.auto_load.ad_load

import com.anythink.core.api.AdError
import com.anythink.interstitial.api.ATInterstitialAutoLoadListener
import com.bp.hearthealth.pulse.lnapps.bp_extension.LogUtil

/**
 * 自动加载  广告加载回调
 */
class ATInterstitialAutoLoadListenerImpl : ATInterstitialAutoLoadListener {

    private var adAutoLoadListener: TopOnInterstitialAutoLoadListener? = null

    fun setAutoLoadListener(topOnInterstitialAutoLoadListener: TopOnInterstitialAutoLoadListener?) {
        this.adAutoLoadListener = topOnInterstitialAutoLoadListener
    }

    override fun onInterstitialAutoLoaded(placementId: String?) {
        adAutoLoadListener?.onInterstitialAutoLoaded(placementId)
        LogUtil.iTopOn("TopOn 插页广告自动加载  PlacementId:$placementId: onInterstitialAutoLoaded")
    }

    override fun onInterstitialAutoLoadFail(placementId: String?, adError: AdError?) {
        adAutoLoadListener?.onInterstitialAutoLoadFail(placementId, adError)
        LogUtil.iTopOn(buildString {
            append("插页广告  PlacementId:")
            append(placementId)
            append(": onInterstitialAutoLoadFail:\n")
            append(adError?.fullErrorInfo)
        })
    }
}